#include <iostream>

class Animal
{
public:
    virtual ~Animal()
    {
        std::cout << "父类的析构函数调用了" << std::endl;
    }

    Animal() {}

    Animal(const Animal& animal) 
    {
        std::cout << "父类的拷贝构造方法执行了" << std::endl;
    }
};

class Dog : public Animal
{
public:
    int *score;
    Dog()
    {
        score = new int(12);
    }
    ~Dog() override
    {   
        std::cout << "子类的析构函数调用了" << std::endl;
        if (score != nullptr) 
        {
            delete score;
            score = nullptr;
        }
    }
};

int main(int argc, char const *argv[])
{
    
    Dog*dog = new Dog();
    Animal* animal = dog;
    delete animal;

    return 0;
}
